package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.PersonalInfo;
import com.eling.elcms.core.dao.annotation.Between;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.privilege.service.impl.CommonPrivilegeCriteriaEnhancer;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;

import javax.persistence.*;
import java.util.Date;

/**
 * 报名登记
 * 
 * @author linjizeng 模型评审：新增模型，wulina 2016-09-07
 *
 */
@Entity
@Indexed
@Table(name = "travel_signupregister")
@CriteriaEnhancers(criteriaEnhancers = {
		@CriteriaEnhancer(impl = CommonPrivilegeCriteriaEnhancer.class, parameter = "servicepoint:planItemGroup.servicePoint") })
public class SignUpRegister extends BaseModel {

	private static final long serialVersionUID = 586449110662237849L;

	@Id
	@In
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@DocumentId
	private Long pkSignUpRegister;

	/** 旅游团和联盟、服务点关系 */
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
	@JoinColumn(name = "pkPlanItemGroup")
	@IndexedEmbedded(depth = 1)
	// TODO 待修改为会员团与报名登记信息的中间关联模型
	private PlanItemGroup planItemGroup;

	/** 报名人 */
	@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
	@JoinColumn(name = "pkPersonalInfo")
	@IndexedEmbedded(depth = 1)
	private PersonalInfo personalInfo;

	/** 合同签约（拼装权证号） */
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkTravelContract")
	@IndexedEmbedded(depth = 1)
	private TravelContract travelContract;

	/** 是否是会员 */
	@Column
	@Field
	private Boolean member;

	/** 是否是客户 */
	@Column
	@Field
	private Boolean customer;

	/** 入住日期 */
	@Column
	@Field
	@Between
	private Date checkInDate;

	/** 退住日期 */
	@Column
	@Field
	@Between
	private Date checkOutDate;

	/** 退住 */
	@Column
	@Field
	@Between
	private Boolean checkOut;

	/** 报名日期 */
	@Field
	@Column
	@Between
	private Date signUpDate;

	/** 紧急联系人--联盟团登记 */
	@Column
	@Field
	private String contactName;

	/** 紧急联系人电话--联盟团登记 */
	@Column
	@Field
	private String contactPhone;

	/** 退团 */
	@Column(columnDefinition="bigint default 0")
	@Field
	private Boolean exitGroup;

	@Version
	private Integer version;
	
	public Long getPkSignUpRegister() {
		return pkSignUpRegister;
	}

	public void setPkSignUpRegister(Long pkSignUpRegister) {
		this.pkSignUpRegister = pkSignUpRegister;
	}

	public PlanItemGroup getPlanItemGroup() {
		return planItemGroup;
	}

	public void setPlanItemGroup(PlanItemGroup planItemGroup) {
		this.planItemGroup = planItemGroup;
	}

	public PersonalInfo getPersonalInfo() {
		return personalInfo;
	}

	public void setPersonalInfo(PersonalInfo personalInfo) {
		this.personalInfo = personalInfo;
	}

	public Boolean getCheckOut() {
		return checkOut;
	}

	public void setCheckOut(Boolean checkOut) {
		this.checkOut = checkOut;
	}

	public TravelContract getTravelContract() {
		return travelContract;
	}

	public void setTravelContract(TravelContract travelContract) {
		this.travelContract = travelContract;
	}

	public Boolean getMember() {
		return member;
	}

	public void setMember(Boolean member) {
		this.member = member;
	}

	public Date getCheckInDate() {
		return checkInDate;
	}

	public void setCheckInDate(Date checkInDate) {
		this.checkInDate = checkInDate;
	}

	public Date getCheckOutDate() {
		return checkOutDate;
	}

	public void setCheckOutDate(Date checkOutDate) {
		this.checkOutDate = checkOutDate;
	}

	public Date getSignUpDate() {
		return signUpDate;
	}

	public void setSignUpDate(Date signUpDate) {
		this.signUpDate = signUpDate;
	}

	public String getContactName() {
		return contactName;
	}

	public void setContactName(String contactName) {
		this.contactName = contactName;
	}

	public String getContactPhone() {
		return contactPhone;
	}

	public void setContactPhone(String contactPhone) {
		this.contactPhone = contactPhone;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Boolean getCustomer() {
		return customer;
	}

	public void setCustomer(Boolean customer) {
		this.customer = customer;
	}

	public Boolean getExitGroup() {
		return exitGroup;
	}

	public void setExitGroup(Boolean exitGroup) {
		this.exitGroup = exitGroup;
	}

}
